﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RPGProject.GameWorld;
using RPGProject.GameWorld.GameObjects;
namespace RPGProject.LoopSystem
{
    /// <summary>
    /// A subclass of loop, that takes care of rendering and sending out frame updates.
    /// </summary>
    class WorldFrameLooper : Loop
    {
        private World world;
        /// <summary>
        /// Basic constructor for a WFL.
        /// </summary>
        /// <param name="w"></param>
        /// <param name="lm"></param>
        public WorldFrameLooper(World w, LoopManager lm)
            : base(lm, 0)
        {
            this.world = w;
        }
        /// <summary>
        /// Overriden abstract RunOnce method, sends out frame event and renders the screen.
        /// </summary>
        /// <returns></returns>
        public override FuncType RunOnce()
        {
            this.world.Listen(new GameObjectEvent("frame"));
            this.world.Render();
            return FuncType.ADD_TO_END;
        }
    }
}
